/*
 * RoboEye - Web client for www.newocr.com that allows you
 * to recognize an image captured by the camera.
 *
 * Copyright (C) Oxygen Development, 2011
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

package com.devoxy.roboeye.global;

import android.content.Context;

/**
 * Created by Oxygen Development.
 * Author: Dmitriy Tarasov (dm.vl.tarasov@gmail.com)
 * Date: 24.07.11
 * Time: 17:26
 */
public class ArrayUtils {

    public static String getValueFromDescription(int descriptionsArray, int valuesArray, String description) {
        Context context = ContextHolder.getInstance().getContext();
        String[] descriptions = context.getResources().getStringArray(descriptionsArray);
        String[] values = context.getResources().getStringArray(valuesArray);

        for (int i = 0; i < descriptions.length; i++) {
            if (descriptions[i].equalsIgnoreCase(description)) {
                return  values[i];
            }
        }
        return null;
    }

    public static String getDescriptionFromValue(int descriptionsArray, int valuesArray, String value) {
        Context context = ContextHolder.getInstance().getContext();
        String[] descriptions = context.getResources().getStringArray(descriptionsArray);
        String[] values = context.getResources().getStringArray(valuesArray);

        for (int i = 0; i < values.length; i++) {
            if (values[i].equalsIgnoreCase(value)) {
                return descriptions[i];
            }
        }
        return null;
    }
}
